﻿namespace Contoso.ActiveDirectory {

    #region Usings
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks; 
    #endregion

    [Serializable]
    public class TelephoneAttributes : ITelephoneAttributes {

        #region Members
        public static readonly string[] AttributesToGet;

        #region HomePhone
        public string HomePhone { get; private set; }
        public string OtherHomePhone { get; private set; }
        #endregion

        #region IpPhone
        public string IpPhone { get; private set; }
        public string OtherIpPhone { get; private set; }
        #endregion

        #region Mobile
        public string Mobile { get; private set; }
        public string OtherMobile { get; private set; }
        #endregion

        #region Pager
        public string Pager { get; private set; }
        public string OtherPager { get; private set; }
        #endregion

        #region PrimaryInternationalISDNNumber
        public string PrimaryInternationalISDNNumber{ get; private set; }
        #endregion

        #region TelephoneNumber
        public string TelephoneNumber { get; private set; }
        public string OtherTelephone { get; private set; } 
        #endregion
        #endregion

        #region Constructors
        static TelephoneAttributes() {
            AttributesToGet = new string[]
            {
                "homePhone",
                "otherHomePhone",
                "ipPhone",
                "otherIpPhone",
                "mobile",
                "otherMobile",
                "primaryInternationalISDNNumber",
                "pager",
                "otherPager",
                "telephoneNumber",
                "otherTelephone"
            };
        }
        public TelephoneAttributes() {
            this.HomePhone = string.Empty;
            this.OtherHomePhone = string.Empty;
            this.IpPhone = string.Empty;
            this.OtherIpPhone = string.Empty;
            this.Mobile = string.Empty;
            this.OtherMobile = string.Empty;
            this.PrimaryInternationalISDNNumber = string.Empty;
            this.Pager = string.Empty;
            this.OtherPager = string.Empty;
            this.TelephoneNumber = string.Empty;
            this.OtherTelephone = string.Empty;
        } 
        #endregion

        #region Methods
        public void ProcessResults(Dictionary<string, object[]> attributes) {
            if (attributes.ContainsKey("homePhone")) this.HomePhone = attributes["homePhone"][0].ToString();
            if (attributes.ContainsKey("otherHomePhone")) this.OtherHomePhone = attributes["otherHomePhone"][0].ToString();
            if (attributes.ContainsKey("ipPhone")) this.IpPhone = attributes["ipPhone"][0].ToString();
            if (attributes.ContainsKey("otherIpPhone")) this.OtherIpPhone = attributes["otherIpPhone"][0].ToString();
            if (attributes.ContainsKey("mobile")) this.Mobile = attributes["mobile"][0].ToString();
            if (attributes.ContainsKey("otherMobile")) this.OtherMobile = attributes["otherMobile"][0].ToString();
            if (attributes.ContainsKey("primaryInternationalISDNNumber")) this.PrimaryInternationalISDNNumber = attributes["primaryInternationalISDNNumber"][0].ToString();
            if (attributes.ContainsKey("pager")) this.Pager = attributes["pager"][0].ToString();
            if (attributes.ContainsKey("otherPager")) this.OtherPager = attributes["otherPager"][0].ToString();
            if (attributes.ContainsKey("telephoneNumber")) this.TelephoneNumber = attributes["telephoneNumber"][0].ToString();
            if (attributes.ContainsKey("otherTelephone")) this.OtherTelephone = attributes["otherTelephone"][0].ToString();
        } 
        #endregion
    }
}
